"""Wrapper for database queries."""

__author__  =  'Tailgunner'
__project__ =  'MW:O Drop Planner'

import logging

from google.appengine.ext        import db
from google.appengine.api        import memcache

from lib.model.Player import Player
from lib.Toolbox      import WebTools

logging.getLogger().setLevel(logging.DEBUG)

class Players():
    
    @classmethod        
    def player_by_name(cls, name):
        """Returns a list of mechs per Drop-ID."""
        
        # fetch from database
        player = None
        
        qtext = "SELECT * FROM Player WHERE name = :1"
               
        query = db.GqlQuery(qtext, name)
        
        for i in query:
            return i
        
        p = Player(name=name, visits=0)
        p.put()
        
        return p